
TRIGGER PROCEDURE FOR WRITE OF ap_MSTR OLD BUFFER OLD_AP_MSTR.

    {mfdeclre.i }
    define new shared work-table wf_old_ap_mstr like ap_mstr.

/* fdn 2009/06/29 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "ap_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(ap_mstr), input "ap_mstr").

    if not can-find ( first dt_mstr where dt_table = "ap_mstr" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_ap_mstr ) then do:
        create wf_old_ap_mstr.
        if recid(wf_old_ap_mstr)= -1 then .
    end.
    
    buffer-copy old_ap_mstr to wf_old_ap_mstr no-error.

    for each dt_mstr no-lock where dt_table = "ap_mstr" and dt_type = "MOD" :
    
        case dt_field :

            when "ap_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_type, input ap_mstr.ap_type,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_ref" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_ref, input ap_mstr.ap_ref,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_batch" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_batch, input ap_mstr.ap_batch,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_vend" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_vend, input ap_mstr.ap_vend,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_effdate" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_effdate), input string(ap_mstr.ap_effdate),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_date), input string(ap_mstr.ap_date),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_amt), input string(ap_mstr.ap_amt),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_acct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_acct, input ap_mstr.ap_acct,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_cc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_cc, input ap_mstr.ap_cc,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_disc_acct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_disc_acct, input ap_mstr.ap_disc_acct,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_disc_cc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_disc_cc, input ap_mstr.ap_disc_cc,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_open" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_open), input string(ap_mstr.ap_open),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_rmk" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_rmk, input ap_mstr.ap_rmk,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_user1, input ap_mstr.ap_user1,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_user2, input ap_mstr.ap_user2,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_curr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_curr, input ap_mstr.ap_curr,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_ex_rate" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_ex_rate), input string(ap_mstr.ap_ex_rate),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_bank" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_bank, input ap_mstr.ap_bank,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_sort" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_sort, input ap_mstr.ap_sort,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_expt_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_expt_date), input string(ap_mstr.ap_expt_date),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_entity" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_entity, input ap_mstr.ap_entity,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_ent_ex" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_ent_ex), input string(ap_mstr.ap_ent_ex),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_ckfrm" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_ckfrm, input ap_mstr.ap_ckfrm,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap__qad01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap__qad01, input ap_mstr.ap__qad01,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap__qad02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap__qad02, input ap_mstr.ap__qad02,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap__qad03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap__qad03), input string(ap_mstr.ap__qad03),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_dy_code" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_dy_code, input ap_mstr.ap_dy_code,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_remit" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_remit, input ap_mstr.ap_remit,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_ex_rate2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_ex_rate2), input string(ap_mstr.ap_ex_rate2),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_ex_ratetype" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_ex_ratetype, input ap_mstr.ap_ex_ratetype,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_base_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_base_amt), input string(ap_mstr.ap_base_amt),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_exru_seq" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ap_mstr.ap_exru_seq), input string(ap_mstr.ap_exru_seq),
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_sub" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_sub, input ap_mstr.ap_sub,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_disc_sub" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_disc_sub, input ap_mstr.ap_disc_sub,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

            when "ap_unapplied_ref" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ap_mstr.ap_unapplied_ref, input ap_mstr.ap_unapplied_ref,
                    input recid(ap_mstr), input ap_mstr.ap_type, input ap_mstr.ap_ref, input "", input "",
                    input "", input "", input "", input "").

        end.

    end.
end.

{hkdttrans.i}
